<?php

class DataObjectTest extends PHPUnit_Framework_TestCase
{
    public function testArrayAccess()
    {
        $dataObject = new \SampleModel\DataObject();
        $dataObject['a'] = 1;
        $this->assertEquals($dataObject['a'], 1);
    }

    public function testObjectAccess()
    {
        $dataObject = new \SampleModel\DataObject();
        $dataObject->a = 1;
        $this->assertEquals($dataObject->a, 1);
    }

    public function testObjectAccessAndArrayAccess()
    {
        $dataObject = new \SampleModel\DataObject();
        $dataObject->a = 1;
        $this->assertEquals($dataObject->a, 1);
        $this->assertEquals($dataObject['a'], 1);

        $dataObject['a'] = 2;
        $this->assertEquals($dataObject->a, 2);
        $this->assertEquals($dataObject['a'], 2);
    }

    public function testToArray()
    {
        $dataObject = new \SampleModel\DataObject();
        $dataObject->a = 1;
        $dataObject['b'] = 2;

        $this->assertEquals(array('a' => 1, 'b' => 2), $dataObject->toArray());
    }
}